from flask import render_template
from flask_login import login_required, current_user

from web import custom


@custom.route('/')
@custom.route('/index')
@login_required
def index():
    '''
    首页
    :return:
    '''

    return render_template("index.html", username=current_user.username)


@custom.route('/page/stock_info')
@login_required
def stock_info():
    '''
    股票
    :return:
    '''

    return render_template("stock_info.html")


@custom.route('/page/stock_holder')
def stock_holder():
    '''
        股票k线图
    :return:
    '''
    return render_template("stock_holders.html")


@custom.route('/page/daily_rise_info')
@login_required
def daily_rise_info():
    '''
    每日涨幅
    :return:
    '''

    return render_template("daily_rise_info.html")


@custom.route('/page/manual_spider')
@login_required
def manual_spider():
    '''
    爬虫
    :return:
    '''

    return render_template("manual_spider.html")


@custom.route('/page/industry/rank')
def industry_ranking():
    '''
    行业排行榜
    :return:
    '''
    return render_template("industry_rank.html")

@custom.route('/page/industry/time')
def industry_ranking_time():
    '''
    行业分时排行榜
    :return:
    '''
    return render_template("industry_rank_time.html")

@custom.route('/page/stock/rank')
def stock_ranking():
    '''
    行业排行榜
    :return:
    '''
    return render_template("stock_rank.html")

@custom.route('/page/stock/pool')
def stock_pool_page():
    '''
    行业排行榜
    :return:
    '''
    return render_template("stock_pool.html")

@custom.route('/page/stock/optional')
def page_stock_optional():
    '''
    自选股
    :return:
    '''
    return render_template("stock_optional.html")

@custom.route('/page/stock_lifeline')
def page_stock_lifeline():
    '''
    自选股
    :return:
    '''
    return render_template("stock_lifeline.html")

@custom.route('/page/news')
def news_info():
    '''
        新闻列表
    :return:
    '''
    return render_template("news.html")

@custom.route('/page/stock')
def stock_kline():
    '''
        股票k线图
    :return:
    '''
    return render_template("klinechart.html")


#Pandas页
# @custom.route('/pandas', methods=("POST", "GET"))
# def GK():
#     return render_template('pandas.html',
#                            PageTitle = "Pandas",
#                            table=[GK_roi.to_html(classes='data', index = False)], titles= GK_roi.columns.values)


#Matplotlib页
@custom.route('/matplot', methods=("POST", "GET"))
def mpl():
    return render_template('matplot.html',
                           PageTitle = "Matplotlib")